//===== eAthena Script ======================================= 
//= Selling,Buying,Trading Broadcaster (SBT/Marketing NPC)
//===== By: ================================================== 
//= Arcenciel
//===== Version and Changes ==================================
//= 1.1		-Finished and released the script
//= 2.0		-Added server wide broadcast
//=		-Fixed Next;
//=		-Fixed Dialogue
//= 3.0		-Optimized by Terces
//=		-Added customizable level restriction,cost,
//=		 GM level use.
//=		-Added GM Menu -option to turn it on or off
//=		-Added Color coding for messages
//= 4.0		-Added automatic disable for WO
//= 5.0		-Optimized the Script
//=		-Added protection using timers for spam abuse
//===== Description: ========================================= 
//= This script is used for marketing purposes. 
//= The NPC generated by this script broadcasts Buying,Selling or
//= Trading messages throughout the server. It also features an
//= enable and disable option for GMs and Time-Disable for lesser 
//= spam abuse. While Time-Disabled, GMs have the option to 
//= remove the Time-Lock.
//===== All credits reserved to Arcenciel ====================
 
prontera,138,224,4	script	Marketer	894,{

setarray .@announcetypes$,"Selling","Buying","Trading","sell","buy","trade","S>","B>","T>","0xFF3333","0x37FDFC","0x4DBD33";

set @uselevel,70; // Change to set level restriction
set @cost,100000; // Change to set the Cost
set @levelgm,30;  // Change to set GM level control
set .marketing,1; // Don't Touch
set .timeout,1; // Don't Touch
set .counting,1; // Don't Touch
set @agit_flag,agitcheck(); //Don't Touch

	if (@agit_flag == 1) {
mes "[Marketing NPC]";
emotion 17;
mes "Sorry but my service is not open during WOE hours.";
mes "Please try again later.";
close;
}
else if (.time == .timeout) {
mes "[Marketing NPC]";
emotion 9;
mes "Sorry,The broadcast network is still busy.";
next;
if (getgmlevel() >= @levelgm) {
mes "[Marketing NPC]";
emotion 0;
mes "Oh! Hi "+strcharinfo(0)+".";
next;
mes "[Marketing NPC]";
mes "Would you like to reestablish the network?";
	if (select("Yes,Please!:No,Thanks!") == 2) goto L_no;
emotion 24;
npctalk "Service has been reestablish by a Game Master";
	set .time,0;
stopnpctimer;
close;
}
mes "[Marketing NPC]";
mes "Check back again later.";
close;
}
else if (BaseLevel < @uselevel) {
mes "[Marketing NPC]";
emotion 16;
mes "Sorry, but your level is not high enough for my services.";
next;
mes "[Marketing NPC]";
mes "Come back when your base level is ^0000FF "+@uselevel+"^000000." ;
close;
}
else if (.market == .marketing) {
mes "[Marketing NPC]";
emotion 4;
mes "I am sorry but I cannot provide you with my service right now.";
next;
	if (getgmlevel() >= @levelgm) {
mes "[Marketing NPC]";
emotion 0;
mes "Oh, I am sorry "+strcharinfo(0)+".";
mes "I didn't notice.";
next;
mes "[Marketing NPC]";
mes "Would you like to reactive the services?";
	if (select("Yes,Please!:No,Thanks!") == 2) goto L_no;
	set .market,0;
emotion 24;
mes "Service is now available.";
npctalk "Service is now made available by a Game Master.";
}
mes "[Marketing NPC]";
mes "Please come back some other time.";
close;
}

mes "[Marketing NPC]";
mes "Hello, Would you like to broadcast something market related?";
emotion 1;
	if (select("Yes,Please!:No,Thanks!") == 2) goto L_no;
mes "Okay, Now choose which you would like to broadcast.";
	if (getgmlevel() >= @levelgm) {
	set .@selection,select("Selling:Buying:Trading:Nothing:GM Menu")-1;
}  
else set .@selection,select("Selling:Buying:Trading:Nothing")-1;
	if (.@selection==3) goto L_no;
	if (.@selection==4) {  
next;
mes "[Marketing NPC]";
mes "Would you like to stop the service?";
	if (select("Yes,Please!:No,Thanks!") == 2) goto L_no;
	set .market,1;
mes "Service is now stopped.";
emotion 25;
npctalk "Service is stopped by a Game Master.";
close;
}
next;
mes "[Marketing NPC]";
mes .@announcetypes$[.@selection]+" it is, however it will cost you ^CC3300"+callfunc("F_intComa",@cost)+"^000000 zeny.";
next;
	if (Zeny < @cost){
mes "[Marketing NPC]";
emotion 4;
mes "Sorry but you don't have enough zeny to pay me.";
close;
}
mes "[Marketing NPC]";
mes "Okay, What item would you like to "+.@announcetypes$[3+.@selection]+"?";
	input .@announce1$;
next;
mes "[Marketing NPC]";
mes "What would you like to "+.@announcetypes$[3+.@selection]+" it for?";
	input .@announce2$;
next;
mes "[Marketing NPC]";
mes "Are you sure you would like to broadcast"; 
mes "^0000FF "+.@announcetypes$[6+.@selection]+" "+.@announce1$+" for "+.@announce2$+"^000000 ?";
	if(select("Yes","No")==2) goto L_no;
next;
	announce strcharinfo(0)+": "+.@announcetypes$[6+.@selection]+" "+.@announce1$+" for "+.@announce2$,bc_all,.@announcetypes$[.@selection+9];
	set Zeny,Zeny-@cost;
	set .time,1;
mes "[Marketing NPC]";
mes "Your advertisement was successfully broadcasted.";
emotion 15;
mes "Thanks for using my services!";
close2;
initnpctimer;
emotion 25;
npctalk "Service Deactivated.";
end;
OnTimer5000: 
npctalk "Service will be resumed after 3 minutes.";     
end;
OnTimer60000:
emotion 10;
npctalk "Service will be resumed after 2 minutes.";
end;
OnTimer120000:
npctalk "Service will be resumed after 1 minute.";
end;
OnTimer180000:
emotion 24;
npctalk "Service Activated.";
	set .time,0;
stopnpctimer; 
end;

L_no:
next;
mes "[Marketing NPC]";
mes "Very well then, Talk to me whenever you need my service.";
emotion 21;
close;


}